<%@ page language="java" import="java.util.*"
	pageEncoding="utf-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%!String[] days;%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'index.jsp' starting page</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	</head>

	<body>
		<%
		    days = new String[42];
		    for (int i = 0; i < 42; i++)
		    {
		        days[i] = "";
		    }
		%>
		<%
		    GregorianCalendar currentDay = new GregorianCalendar();
		    int today = currentDay.get(Calendar.DAY_OF_MONTH);
		    int month = currentDay.get(Calendar.MONTH);
		    int year = currentDay.get(Calendar.YEAR);
		    Calendar thisMonth = Calendar.getInstance();
		    thisMonth.set(Calendar.MONTH, month);
		    thisMonth.set(Calendar.YEAR, year);
		    thisMonth.setFirstDayOfWeek(Calendar.SUNDAY);
		    thisMonth.set(Calendar.DAY_OF_MONTH, 1);
		    int firstIndex = thisMonth.get(Calendar.DAY_OF_WEEK) - 1;
		    int maxIndex = thisMonth.getActualMaximum(Calendar.DAY_OF_MONTH);
		    for (int i = 0; i < maxIndex; i++)
		    {
		        days[firstIndex + i] = String.valueOf(i + 1);
		    }
		%>
		<h2 align="center"><%=year + "年" + (month + 1) + "月" + today + "日" %></h2>
		<table border="1" align="center">
			<div>
				<tr  valign="middle" align="center">
					<th>
						<font color="red">日</font>
					</th>
					<th>
						一
					</th>
					<th>
						二
					</th>
					<th>
						三
					</th>
					<th>
						四
					</th>
					<th>
						五
					</th>
					<th>
						<font color="red">六</font>
					</th>
				</tr>
				<%
				    for (int j = 0; j < 6; j++)
				    {
				%>
			
			<tr>
				<%
				    for (int i = j * 7; i < (j + 1) * 7; i++)
				        {
				%>
				<td>
					<%
					    if ((i - firstIndex + 1) == today)
					            {
					%>
					<div style="width: 50 ;height: 50; text-align:center"><font color="red"><%=days[i]%></font></div>
					
					<%
					    }
					            else
					            {
					%>
					<div style="width: 50 ;height: 50; text-align:center"><%=days[i]%></div>
					<%
					    }
					%>
				</td>
				<%
				    }
				%>
			</tr>
			<%
			    }
			%>
			</div>
		</table>
	</body>
</html>
